package models;

import util.RoutePointBuilder;

import java.util.LinkedList;
import java.util.Queue;

import static util.RouteConstansts.*;

/**
 * Created by IntelliJ IDEA.
 * User: Julioagh
 * Date: 02/10/11
 * Time: 02:10 PM
 * To change this template use File | Settings | File Templates.
 */
public class RouteMatrixBuilder {


    public static Queue<RoutePoint> createOptimizedRouteExpected() {
        RoutePoint r1 = RoutePointBuilder.createRoutePoint(1l, "r1");
        RoutePoint r2 = RoutePointBuilder.createRoutePoint(2l, "r2");
        RoutePoint r3 = RoutePointBuilder.createRoutePoint(3l, "r3");
        RoutePoint r4 = RoutePointBuilder.createRoutePoint(4l, "r4");
        RoutePoint r5 = RoutePointBuilder.createRoutePoint(5l, "r5");
        /*Ruta optima es 1 5 3 2 4*/

        Queue<RoutePoint> route = new LinkedList<RoutePoint>();
        route.add(r1);
        route.add(r5);
        route.add(r3);
        route.add(r2);
        route.add(r4);
        return route;  //To change body of created methods use File | Settings | File Templates.
    }

    public static Queue<RoutePoint> createOptimizedRouteExpected2() {
        RoutePoint r1 = RoutePointBuilder.createRoutePoint(1l, "r1");
        RoutePoint r2 = RoutePointBuilder.createRoutePoint(2l, "r2");
        RoutePoint r3 = RoutePointBuilder.createRoutePoint(3l, "r3");
        RoutePoint r4 = RoutePointBuilder.createRoutePoint(4l, "r4");
        RoutePoint r5 = RoutePointBuilder.createRoutePoint(5l, "r5");
        /*Ruta optima es 1 5 3 2 4*/

        Queue<RoutePoint> route = new LinkedList<RoutePoint>();
        route.add(r1);
        route.add(r5);
        route.add(r3);
        route.add(r4);
        route.add(r2);
        return route;  //To change body of created methods use File | Settings | File Templates.
    }
/*
*   1  2  3  4  5
1  0  0  0  0  0
2 34  0  0  0  0
3 49  5  0  0  0
4 42 41 28  0  0
5 13 42 11 24  0

1 5 3 2 4 r.o
* */
    public static int[][] createLowlyTriangularMatrix() {
        int[][] matrix = new int[MATRIX_ORDER][MATRIX_ORDER];
        for (int i = 0; i < matrix.length; i++) {
            int[] rows = matrix[i];
            for (int j = 0; j < rows.length; j++) {
                int actualValue = MATRIX_NONZERO_VALUE;
                if (i < j) actualValue = MATRIX_ZERO_VALUE;
                if (i == j) actualValue = MATRIX_ZERO_VALUE;
                matrix[i][j] = actualValue;
            }
        }

        /*0*/                           /*0*/                      /*0*/                 /*0*/            /*0*/
        matrix[1][0] = 34;              /*0*/                      /*0*/                 /*0*/            /*0*/
        matrix[2][0] = 49;         matrix[2][1] = 5;               /*0*/                 /*0*/            /*0*/
        matrix[3][0] = 42;         matrix[3][1] = 41;       matrix[3][2] = 28;           /*0*/            /*0*/
        matrix[4][0] = 13;         matrix[4][1] = 42;       matrix[4][2] = 11;      matrix[4][3] = 24;    /*0*/

        return matrix;
    }


         /*
  1  2  3  4  5
1  0  0  0  0  0
2 34  0  0  0  0
3 49 28  0  0  0
4 42 41  5  0  0
5 13 42 11 24  0

1 5 3 4 2
       * */
    public static int[][] createLowlyTriangularMatrix2() {
        int[][] matrix = new int[MATRIX_ORDER][MATRIX_ORDER];
        for (int i = 0; i < matrix.length; i++) {
            int[] rows = matrix[i];
            for (int j = 0; j < rows.length; j++) {
                int actualValue = MATRIX_NONZERO_VALUE;
                if (i < j) actualValue = MATRIX_ZERO_VALUE;
                if (i == j) actualValue = MATRIX_ZERO_VALUE;
                matrix[i][j] = actualValue;
            }
        }
        /*0*/                 /*0*/                     /*0*/               /*0*/           /*0*/
        matrix[1][0] = 34;    /*0*/                     /*0*/               /*0*/           /*0*/
        matrix[2][0] = 49;    matrix[2][1] = 28;        /*0*/               /*0*/           /*0*/
        matrix[3][0] = 42;    matrix[3][1] = 41;  matrix[3][2] = 5;        /*0*/            /*0*/
        matrix[4][0] = 13;    matrix[4][1] = 42;  matrix[4][2] = 11;   matrix[4][3] = 24;   /*0*/

        return matrix;
    }

}